﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="Edit.aspx.cs" Inherits="sistemaAcademicoFinanceiroEscolas.aulasEdit.Edit" %>



<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />

    <div class="tamanho">
    
<h2>Modificar Aula</h2>
    

    
    
    

    <asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" />

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                HeaderText="Lista de erros de validação" />
            <asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="DetailsView1" Display="None" />


            
             <asp:DetailsView ID="DetailsView1" runat="server" 
                DataSourceID="DetailsDataSource" DefaultMode="Edit"
                AutoGenerateEditButton="False" AutoGenerateDeleteButton="False" OnItemCommand="DetailsView1_ItemCommand" 
                OnItemUpdated="DetailsView1_ItemUpdated"
                CssClass="detailstable" FieldHeaderStyle-CssClass="bold" 
                AutoGenerateRows="False">
                <FieldHeaderStyle CssClass="bold" />
                <Fields>
                
                    
                    <asp:DynamicField DataField="valorPago" HeaderText="Valor pago pelo aluno " />
                    <asp:DynamicField DataField="valorPagoProfessor" HeaderText="Valor pago ao professor " />
                    
                    
                    <asp:TemplateField ShowHeader="False">
                    
  
                    
                     <EditItemTemplate>                                                         
                                <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="True" 
                                CommandName="Update" Text="Salvar" OnClientClick="return validar();" ></asp:LinkButton>
                            &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                                CommandName="Cancel" Text="Cancelar"></asp:LinkButton>                                
                        </EditItemTemplate>
                    </asp:TemplateField>
                </Fields>
            </asp:DetailsView>
            
            
            

            <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableUpdate="true">
                <WhereParameters>
                    <asp:DynamicQueryStringParameter />
                </WhereParameters>
            </asp:LinqDataSource>
            
            <Script language="javascript">



                function validar() {

                    for (i = 0; i < document.aspnetForm.elements.length; i++) {

                        //localizar o nome do campo

                        var encontrouDesc = document.aspnetForm.elements[i].name.indexOf("valorPago");

                        if (encontrouDesc >= 0) {

                            //validar


                            if (document.aspnetForm.elements[i].value == "") {

                                alert('O valor deve ser informado.');
                                document.aspnetForm.elements[i].focus();
                                return false;

                                // Fim segundo IF
                            }

                            var valor = document.aspnetForm.elements[i].value.toString();
                            var digito = "";

                            for (iz = 0; iz < valor.length; iz++) {

                                digito = valor.substr(iz, 1);


                                if ((digito != "0") && (digito != "1") && (digito != "2") && (digito != "3") && (digito != "4") && (digito != "5") && (digito != "6") && (digito != "7") && (digito != "8") && (digito != "9") && (digito != ",")) {

                                    alert('O valor deve conter apenas numeros e virgulas.');
                                    document.aspnetForm.elements[i].focus();
                                    return false;

                                }
                            }
                        }


                        for (i = 0; i < document.aspnetForm.elements.length; i++) {

                            //localizar o nome do campo

                            var encontrouDesc = document.aspnetForm.elements[i].name.indexOf("valorPagoProfessor");

                            if (encontrouDesc >= 0) {

                                //validar


                                if (document.aspnetForm.elements[i].value == "") {

                                    alert('O valor ao professor deve ser informado.');
                                    document.aspnetForm.elements[i].focus();
                                    return false;

                                    // Fim segundo IF
                                }

                                var valor = document.aspnetForm.elements[i].value.toString();
                                var digito = "";

                                for (iz = 0; iz < valor.length; iz++) {

                                    digito = valor.substr(iz, 1);


                                    if ((digito != "0") && (digito != "1") && (digito != "2") && (digito != "3") && (digito != "4") && (digito != "5") && (digito != "6") && (digito != "7") && (digito != "8") && (digito != "9") && (digito != ",")) {

                                        alert('O valor ao professor deve conter apenas numeros e virgulas.');
                                        document.aspnetForm.elements[i].focus();
                                        return false;

                                    }
                                }
                            }
                        } 
                    }

                    //Fim da função validar  
                }
                // Fim do script
            </script>
            
           
            
        </ContentTemplate>
    </asp:UpdatePanel>
    
    </div>
    
</asp:Content>
